package com.ktjy.thymeleaf.service.impl;

import com.ktjy.thymeleaf.entity.User;
import com.ktjy.thymeleaf.mapper.UserMapper;
import com.ktjy.thymeleaf.service.IUserService;

import jakarta.annotation.Resource;

import java.util.List;

public class UserServiceimpl implements IUserService {
    @Resource
    private UserMapper userMapper;

    @Override
    public User login(String uerName, String uerPassword) {
        /*User user=userMapper.getUserListWithRoleName(uerName);
        if (user !=null){
            if (user.getUserPassword().equals(userPassword)){
                return user;
            }
        }*/
        return null;
    }

    @Override
    public int addUser(User user) {
        return userMapper.insert(user);
    }

    @Override
    public int deleteUser(Long usrId) {
        return userMapper.deleteById(usrId);
    }

    @Override
    public int updateUser(User user) {
        return userMapper.updateById(user);
    }

    @Override
    public User getUser(Long usrId) {
        return (User) userMapper.selectById(usrId);
    }

    @Override
    public List<User> findAllUsers() {
        return userMapper.getUserListWithRoleName();
    }
}
